
<head>
<title>Change Price</title>

<script src="javascript/jsonHelp.js"></script>
<script type="text/javascript" src="javascript/dojo.js" djConfig="parseOnLoad: true, usePlainJson:true" >
</script>
<script language="JavaScript">



function validate()
{

   dojo.xhrPost({
        url: 'priceChange_ajax.do',
        sync: false,
        content:  {"jsonAttr":dojo.formToJson(document.mainform)},
        handleAs: "json",
        load: function(data, ioargs) {
            var hasErrors = showErrorsInPlace(data)
            disableSubmit(hasErrors)
            showPartials(data)
        },
        error: function(type, err) {
	    	alert("Error communicating with server. Mostlikely this means your session has timed out")
        }
    });

}

function disableSubmit(tf){
            var submitter = document.getElementById('submitButton')
            submitter.disabled = tf
}

function curious(){
	var submitter = document.getElementById('submitButton')
	if(submitter.disabled)
		validate()
}

function init(){
        //Part of jsonInit is to provide ids to form elements in cases where you've only denoted names.
        //This knowledge may save you some tedium.
	data = jsonInit(<%=request.getAttribute("jsonAttr")%>)
}

dojo.addOnLoad(init);

</script>

</head>
<body>


<h1>Price Change for Product:  <%=session.getAttribute("product").description %> in Category: <%=session.getAttribute("product").categoryname %></h1>
<p>Current price:  <%=session.getAttribute("product").price %> </p>
<div id="priceChangePartial"> </div>


<form method="post" name='mainform' action="priceChange_savePriceChange.do">  
	<table width="95%" bgcolor="f8f8ff" border="0" cellspacing="0" cellpadding="5">    
		<tr>      
			<td alignment="right" width="20%">Increase:</td>      
			        
				<td width="20%">          
					<input type="text" name="increase" value="" onkeydown="disableSubmit(true);"  onblur="validate();">   
				</td>        
				<td width="60%">          
					<font color="red"><div id="increaseError"></div></font>        
				</td>      
			  
		</tr> 
		<tr>  
			<td alignment="right" width="20%">Comment :</td> 
			        
				<td width="20%">          
					<input type="text" name="note" value="" onkeydown="disableSubmit(true);" onblur="validate();">   
				</td>        
				<td width="60%">          
					<font color="red"><div id="noteError"></div></font>        
				</td>      
			   			  
		</tr>  
		<tr>  
			<td alignment="right" width="20%"></td> 
			              
				<td width="60%">          
					<font color="red"></font>        
				</td>      
			   			  
		</tr>  		
	</table>  
	<br>  
	  
	<br><br>  
	<div onmouseover="curious();">
	<input type="submit" name="submitButton" alignment="center" value="Execute" disabled="true" onmouseover="curious();" onclick="doJsonSubmit();">
	</div>
</form>
</body>
</html>